#ifndef __GDB_H__
#define __GDB_H__
#include "config.h"

#define VGDB_OUTP_BLEN  128
#define VGDB_OUTP_BNR   128

#define VGDB_GS_QUIT    0
#define VGDB_GS_STOP    1
#define VGDB_GS_RUN     2


typedef struct{
    pid_t       pid;
    int         state;
    int         rwfd;
    char        symfn[VGDB_FN_LEN];
    char        outp[VGDB_OUTP_BLEN][VGDB_OUTP_BNR];
    int         blen;
    int         bnr;
    int         bcur;
}gdb_t;
extern gdb_t    g_gdb_instance;


extern void gdb_start();
extern void gdb_init();
extern int  gdb_outp();
extern int  gdb_opto();

#define gdb()           (&g_gdb_instance)
#define gdb_inpt(str)   (write(gdb()->rwfd, (str), strlen(str)))
#define gdb_exec(str)   do{DEBUG_MESSAGE("gdb cmd: %s\n",str);gdb_inpt(str);gdb_opto("\x1a\x1apost-prompt");gdb_outp();}while(0)
#define gdb_opln(n)     ((char*)((gdb()->outp)[n]))


#endif
